﻿using ERP_RORZE_DLL.Product.Base;
using ERP_RORZE_DLL.Product.database;
using System;using ERP_RORZE_SYSTEM;
using System.Collections.Generic;
using System.Data;using ERP_RORZE_SYSTEM;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ERP_RORZE_PRODUCT.Product.database;

namespace ERP_RORZE_DLL.Product.DAO
{
    public class ClsBasicListDAO : ExecuteSQL
    {
        ExecuteSQL Execute = new ExecuteSQL();
        /// <summary>
        /// Các hàm lấy dữ liệu
        /// </summary>
        public DataTable GetAllSection()
        {
            string sql = clsConstBasicListFuction.ClsSectionFuction.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        
        }

        public DataTable GetAllWork()
        {
            string sql = clsConstBasicListFuction.ClsWorkFuction.GetAll;
            return Execute.DoStoreProcedure(sql, true);

        }

        public DataTable GetAllOption()
        {
            string sql = clsConstantsFuction.ClsFuctionOption.GetAll;
            return Execute.DoStoreProcedure(sql, true);

        }

        public DataTable GetAlJig()
        {
            string sql = clsConstBasicListFuction.ClsJigFuction.GetAll;
            return Execute.DoStoreProcedure(sql, true);

        }

        public DataTable GetAllExpence()
        {
            string sql = clsConstBasicListFuction.ClsExpenceFuction.GetAll;
            return Execute.DoStoreProcedure(sql, true);

        }

        public DataTable GetAllCustomer()
        {
            string sql = clsConstBasicListFuction.ClsCustomerFuction.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllOvertime()
        {
            string sql = clsConstBasicListFuction.ClsOvertimeFuction.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        /// <summary>
        /// Các hàm Xóa
        /// </summary>
        /// 
        public void DeleteSection(Section b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Section.SectionID, SqlDbType.NVarChar, b.SectionID)
                    
                };
            Execute.DoDelete(clsConstBasicListFuction.ClsSectionFuction.Delete, parameter, true);

        }

        public void DeleteWork(Work b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Work.WorkID, SqlDbType.NVarChar, b.WorkID)
                    
                };
            Execute.DoDelete(clsConstBasicListFuction.ClsWorkFuction.Delete, parameter, true);

        }

        public void DeleteOption(ClsOptionTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsOptionSP.OptionID, SqlDbType.NVarChar, b.OptionID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionOption.Delete, parameter, true);

        }

        public void DeleteJig(Jig b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Jig.JigName, SqlDbType.NVarChar, b.JigName)
                    
                };
            Execute.DoDelete(clsConstBasicListFuction.ClsJigFuction.Delete, parameter, true);

        }

        public void DeleteExpence(Expence b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Expence.ExpenceID, SqlDbType.NVarChar, b.ExpenceID)
                    
                };
            Execute.DoDelete(clsConstBasicListFuction.ClsExpenceFuction.Delete, parameter, true);

        }

        public void DeleteCustomer(ClsCustomerTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CustomerID, SqlDbType.NVarChar, b.CustomerID)
                    
                };
            Execute.DoDelete(clsConstBasicListFuction.ClsCustomerFuction.Delete, parameter, true);

        }

        public void DeleteOvertime(ClsOvertime b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstBasicListFuction.ClsCustomerFuction.Delete, parameter, true);

        }

        /// <summary>
        /// Các hàm nhập
        /// </summary>
        /// 
        public void InsertSection(Section b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Section.SectionID, SqlDbType.NVarChar, b.SectionID),
                    CreateParameter(clsConstBasicListSP.Section.SectionName, SqlDbType.NVarChar, b.SectionName)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsSectionFuction.Insert, parameter, true);

        }

        public void InsertWork(Work b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Work.WorkID, SqlDbType.NVarChar, b.WorkID),
                    CreateParameter(clsConstBasicListSP.Work.WorkName, SqlDbType.NVarChar, b.WorkName),
                    CreateParameter(clsConstBasicListSP.Work.DirectWork, SqlDbType.Bit, b.DirectWork),
                    CreateParameter(clsConstBasicListSP.Work.MachInDWork, SqlDbType.Bit, b.MachInDWork),
                    CreateParameter(clsConstBasicListSP.Work.MachineRun, SqlDbType.Bit, b.MachineRun),
                    CreateParameter(clsConstBasicListSP.Work.MachWork, SqlDbType.Bit, b.MachWork)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsWorkFuction.Insert, parameter, true);

        }

        public void InsertOption(ClsOptionTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsOptionSP.OptionID, SqlDbType.NVarChar, b.OptionID),
                    CreateParameter(clsConstantsSP.ClsOptionSP.OptionName, SqlDbType.NVarChar, b.OptionName),
                    CreateParameter(clsConstantsSP.ClsOptionSP.Labor, SqlDbType.Bit, b.Labor)
                    
                };
            Execute.DoInsert(clsConstantsFuction.ClsFuctionOption.Insert, parameter, true);

        }

        public void InsertJig(Jig b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Jig.JigName, SqlDbType.NVarChar, b.JigName),
                    CreateParameter(clsConstBasicListSP.Jig.JigType, SqlDbType.NVarChar, b.JigType)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsJigFuction.Insert, parameter, true);

        }

        public void InsertExpence(Expence b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Expence.ExpenceID, SqlDbType.NVarChar, b.ExpenceID),
                    CreateParameter(clsConstBasicListSP.Expence.LaborExp, SqlDbType.Bit, b.LaborExp),
                    CreateParameter(clsConstBasicListSP.Expence.Description, SqlDbType.NVarChar, b.Description)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsExpenceFuction.Insert, parameter, true);

        }

        public void InsertCustomer(ClsCustomerTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CustomerID, SqlDbType.NVarChar, b.CustomerID),
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CustomerName, SqlDbType.NVarChar, b.CustomerName),
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CusInfo, SqlDbType.NVarChar, b.CusInfo)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsCustomerFuction.Insert, parameter, true);
        }

        public void InsertOvertime(ClsOvertime b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.Date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.StaffID, SqlDbType.NVarChar, b.StaffID),
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.Time, SqlDbType.Int, b.Time)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsOvertimeFuction.Insert, parameter, true);
        }

        /// <summary>
        /// Các hàm sửa
        /// </summary>
        /// 
        public void UpdateSection(Section b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Section.SectionID, SqlDbType.NVarChar, b.SectionID),
                    CreateParameter(clsConstBasicListSP.Section.SectionName, SqlDbType.NVarChar, b.SectionName)
                    
                };
            Execute.DoUpdate(clsConstBasicListFuction.ClsSectionFuction.Update, parameter, true);

        }

        public void UpdateWork(Work b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Work.WorkID, SqlDbType.NVarChar, b.WorkID),
                    CreateParameter(clsConstBasicListSP.Work.WorkName, SqlDbType.NVarChar, b.WorkName),
                    CreateParameter(clsConstBasicListSP.Work.DirectWork, SqlDbType.Bit, b.DirectWork),
                    CreateParameter(clsConstBasicListSP.Work.MachInDWork, SqlDbType.Bit, b.MachInDWork),
                    CreateParameter(clsConstBasicListSP.Work.MachineRun, SqlDbType.Bit, b.MachineRun),
                    CreateParameter(clsConstBasicListSP.Work.MachWork, SqlDbType.Bit, b.MachWork)
                    
                };
            Execute.DoUpdate(clsConstBasicListFuction.ClsWorkFuction.Update, parameter, true);

        }

        public void UpdateOption(ClsOptionTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsOptionSP.OptionID, SqlDbType.NVarChar, b.OptionID),
                    CreateParameter(clsConstantsSP.ClsOptionSP.OptionName, SqlDbType.NVarChar, b.OptionName),
                    CreateParameter(clsConstantsSP.ClsOptionSP.Labor, SqlDbType.Bit, b.Labor)
                    
                };
            Execute.DoUpdate(clsConstantsFuction.ClsFuctionOption.Update, parameter, true);

        }

        public void UpdateJig(Jig b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Jig.JigName, SqlDbType.NVarChar, b.JigName),
                    CreateParameter(clsConstBasicListSP.Jig.JigType, SqlDbType.NVarChar, b.JigType)
                    
                };
            Execute.DoUpdate(clsConstBasicListFuction.ClsJigFuction.Update, parameter, true);

        }

        public void UpdateExpence(Expence b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.Expence.ExpenceID, SqlDbType.NVarChar, b.ExpenceID),
                    CreateParameter(clsConstBasicListSP.Expence.LaborExp, SqlDbType.Bit, b.LaborExp),
                    CreateParameter(clsConstBasicListSP.Expence.Description, SqlDbType.NVarChar, b.Description)
                    
                };
            Execute.DoUpdate(clsConstBasicListFuction.ClsExpenceFuction.Update, parameter, true);

        }

        public void UpdateCustomer(ClsCustomerTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CustomerID, SqlDbType.NVarChar, b.CustomerID),
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CustomerName, SqlDbType.NVarChar, b.CustomerName),
                    CreateParameter(clsConstBasicListSP.ClsCustomerSP.CusInfo, SqlDbType.NVarChar, b.CusInfo)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsCustomerFuction.Update, parameter, true);
        }

        public void UpdateOvertime(ClsOvertime b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.ID, SqlDbType.Int, b.ID),
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.Date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.StaffID, SqlDbType.NVarChar, b.StaffID),
                    CreateParameter(clsConstBasicListSP.ClsOvertimeSP.Time, SqlDbType.Int, b.Time)
                    
                };
            Execute.DoInsert(clsConstBasicListFuction.ClsOvertimeFuction.Update, parameter, true);
        }

    }
}
